package com.hanserwei.mydemo.stream;

import java.util.Comparator;
import java.util.stream.Stream;

public class SortedTest1 {
    public static void main(String[] args) {
        // 排序
        Stream.of(
                        new Hero("令狐冲", 90),
                        new Hero("风清扬", 98),
                        new Hero("独孤求败", 100),
                        new Hero("方证", 92),
                        new Hero("东方不败", 98),
                        new Hero("冲虚", 90),
                        new Hero("向问天", 88),
                        new Hero("任我行", 92),
                        new Hero("不戒", 88)
                ).sorted(Comparator.comparingInt(Hero::strength).thenComparingInt(h->h.name().length()))
                .forEach(System.out::println);
    }

    record Hero(String name, int strength) {

    }
}
